package view
{
	import assets.view.FooterViewSymbol;
	
	import flash.display.Graphics;
	import flash.geom.Vector3D;
	import flash.text.TextFieldAutoSize;
	
	import model.vo.ViewVO;

	public class FooterView extends FooterViewSymbol
	{
		public static const NAME:String 				= "FooterView";
		
		private var viewData:ViewVO;

		private var labelColor:int;
		private var labelText:String;
		
		private var footerViewWidth:Number;
		private var footerViewHeight:Number;
		
		private var footerViewVecArt:Vector.<Vector3D>;
		
		public function FooterView()
		{
			this.alpha = 1;
		}
		
		public function init( viewVO:ViewVO ):void
		{
			viewData			= viewVO;
			
			setFooterViewProperties();
			buildFooterView();
		}
		
		public function show():void
		{
			labelText = viewData.footerText;
			label.text = labelText;
			FX.fadeIn( label );
		}
		
		private function setFooterViewProperties():void
		{
			footerViewWidth 	= viewData.FOOTER_WIDTH;
			footerViewHeight 	= viewData.FOOTER_HEIGHT;
			
			labelColor 			= viewData.FOOTER_TEXT_COLOR;
		}
		
		private function buildFooterView():void
		{
			label.autoSize = TextFieldAutoSize.LEFT;
			label.textColor = labelColor;
			label.alpha = 0;
			
			footerViewVecArt = new Vector.<Vector3D>();
			
			footerViewVecArt.push( new Vector3D( 0, 0 ) );
			footerViewVecArt.push( new Vector3D( 0, footerViewHeight ) );
			footerViewVecArt.push( new Vector3D( footerViewWidth, footerViewHeight ) );
			footerViewVecArt.push( new Vector3D( footerViewWidth, 0 ) );
			
			FX.spawnFrame( frameContainer, footerViewVecArt, footerSpawnCompleteHandler, viewData );
		}
		
		private function footerSpawnCompleteHandler():void
		{
			var g:Graphics = frameContainer.graphics;
			g.clear();
			g.lineStyle( viewData.LINE_WEIGHT, viewData.LINE_COLOR );
			g.drawRect( 0, 0, footerViewWidth, footerViewHeight );
		}
	}
}